// pages/withdrawal/withdrawal.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    money: '0.00',
  },
  //提交
  formSubmit: function (e) {
    var that = this;
    var uname = e.detail.value.uname;
    var kaihu = e.detail.value.kaihu;
    var card = e.detail.value.card;
    var money = e.detail.value.money;
    let bid = wx.getStorageSync('bid');
    let uid = wx.getStorageSync('userinfo').uid;
    if (!money) {
      wx.showModal({
        title: '金额不能为空',
      })
      return false;
    }
    if (!uname) {
      wx.showModal({
        title: '请输入姓名',
      })
      return false;
    }
    if (!kaihu) {
      wx.showModal({
        title: '请输入开户行',
      })
      return false;
    }
    if (!card) {
      wx.showModal({
        title: '请输入银行卡',
      })
      return false;
    }
    else{
      wx.request({
        url: app.appUrl + '/User/withdraw',
        method: 'POST',
        data: {
          bid: bid,
          uid: uid,
          uname:uname,
          kaihu:kaihu,
          card:card,
          money:money
        },
        success: function (res) {
          console.log(res)
          if(res.data){
            wx.showToast({
              title: '提交成功',
              icon: 'success',
              duration: 2000,
              success: function () {
                app.navTo('../money/money');
              }
            })
          }
        }
      })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      money:options.money
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})